﻿<%@ WebHandler Language="C#" Class="doReply" %>

using System;
using System.Web;
using System.Web.SessionState;

public class doReply : IHttpHandler,IRequiresSessionState {
    
    public void ProcessRequest (HttpContext context) {
        BLL.Message bllmessage = new BLL.Message();
        MODEL.Message model = new MODEL.Message();
        if (common.isLoginOrNot())
        {
            int mfromuid = ((MODEL.Users)context.Session["currentUser"]).UId;
            if (context.Request["mfromuid"] != null && context.Request["reply"] != null && context.Request["mlid"] != null)
            {
                int mlid = Convert.ToInt32(context.Request["mlid"]);
                //注意这里
                int mpfromuid = Convert.ToInt32(context.Request["mfromuid"]);
                string mcontent = context.Request["reply"].ToString();
                
                BLL.Users blluser = new BLL.Users();
                mcontent = "回复" + blluser.getModel(mpfromuid).UName + ":" + mcontent;

                model.MLId = mlid;
                model.MFromUId = mfromuid;
                model.MPFromUId = mpfromuid;
                model.MContent = mcontent;

                if (bllmessage.takeAMessage(model))
                {
                    context.Response.Write("yes");
                }
                else
                {
                    context.Response.Write("no");
                }
            }
            else
            {
                context.Response.Write("no");
            }
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}